package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 执行DML语句-UPDATE
 */
public class JDBCDemo3 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "192045");
        Statement state = conn.createStatement();
        String sql = "UPDATE userinfo " +
                     "SET passward = '6666666' " +
                     "WHERE username = '张三'";

        int num = state.executeUpdate(sql);
        if(num > 0){
            System.out.println("更新成功");
        }else{
            System.out.println("更新失败");
        }

        conn.close();
    }
}
